﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestLinq.Entities;

namespace TestLinq
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("---Start---");
            using (var data = new  TestLinq.Data.TestDataContext())
            {
               var list  = from p in data.DangNhap select p;
               foreach (var item in list)
               {
                   Console.WriteLine("UserName: " + item.UserName + "   ; FullName: " + item.FullName);
                   Console.WriteLine("-------");
               }

               Console.WriteLine("Get user by username:");

               var user = "quyit91";
               var use = data.DangNhap.FirstOrDefault(p => p.UserName== user);// select top 1 * from dangnhap where usernam = 'quyit91'
               Console.WriteLine("UserName: " + use.UserName + "   ; FullName: " + use.FullName);
            }
            Console.WriteLine("--Theam User---");
            DangNhapInfo info = new DangNhapInfo();
            info.UserName = Console.ReadLine();
            info.FullName = Console.ReadLine();
            info.Password = Console.ReadLine();
            info.PhanQuyen  =Convert.ToInt32(  Console.ReadLine());
            Data.DangNhapProvider.Thepmoi(info);
            Console.WriteLine("--END---");
            Console.ReadLine();
        }
    }
}
